 begintownscript;	

 variables;
int i,j,k,r1,choice;
body;
beginstate INIT_STATE;

	if (get_flag(3,2) >= 2) {
		erase_char(10);
		erase_char(14);
}

	if (get_flag(2,8) == 1)
		erase_char(9);

	add_char_to_group(11,1);
	add_char_to_group(12,1);
	add_char_to_group(13,1);

	add_char_to_group(28,1);
	add_char_to_group(29,1);
	add_char_to_group(30,1);
	add_char_to_group(31,1);
	add_char_to_group(32,1);
	add_char_to_group(33,1);
	add_char_to_group(34,1);
	add_char_to_group(37,1);
	add_char_to_group(42,1);
	add_char_to_group(43,1);
	add_char_to_group(44,1);

	set_crime_tolerance(1);

	if (get_flag(3,2) == 1) {
		if (get_flag(2,9) == 0)
			message_dialog("You re-enter the barren fort of the ogre. There are definitely less ogres about than during your previous visit. It would appear that the ogres have indeed attacked somewhere. However, the ogre fort is by no means empty.","The ogres present are also not so friendly anymore.");
		set_flag(2,9,1);
		make_town_hostile();
		erase_char(1001);
		erase_char(10);
		erase_char(14);
		set_items_not_property();
}

	set_name(9,"Chainhound");
	set_name(11,"Ogre Merchant");
	set_name(12,"Ogre Merchant");
	set_name(13,"Ogre Merchant");
	set_name(36,"Angry Ogre");

	if ((get_flag(2,6) == 0) && (get_flag(0,13) == 0)) {
		reset_dialog();
		add_dialog_str(0,"You approach the ogre fort. Its crude stone walls tower in front of you. Much like Passton, the fort has no actual gate to keep intruders out. It simply has an opening in the wall that serves as a choke point.",0);
		add_dialog_str(1,"A group of about a half a dozen ogres waits for you behind the opening. Their expressions are serious, even a little hostile. They gaze at you intently, waiting for you to reveal your intentions. What are they?",0);
		add_dialog_choice(0,"Proceed peacefully.");
		add_dialog_choice(1,"Pull out your weapons! Charge up your spell casters!");
		choice = run_dialog(1);

	if (choice == 2) {
		make_town_hostile();
		put_object_on_space(11,6,4);
		put_object_on_space(12,6,4);
		put_object_on_space(13,6,4);
		erase_char(14);
		set_items_not_property();
		set_flag(3,2,2);
}
		set_flag(2,6,1);
}

	if ((get_flag(2,6) == 0) && (get_flag(0,13) == 1)) {
		message_dialog("As was to be expected, the ogres noticed your military envoy, figured out your intentions, and prepared for your attack. It is going to be a tough fight!","");
		make_town_hostile();
		put_object_on_space(11,6,4);
		put_object_on_space(12,6,4);
		put_object_on_space(13,6,4);
		erase_char(14);
		set_flag(2,6,1);
		set_flag(0,13,2);
		activate_hidden_group(3);
		set_items_not_property();
}
	 break;	

beginstate START_STATE;

	if ((get_ran(1,0,100) < 8) && (town_status(-1) != 2))
		text_bubble_on_char(36,"Urg! Humun!");
	if ((get_ran(1,0,100) < 8) && (town_status(-1) != 2))
		text_bubble_on_char(36,"Blargh!");
	if ((get_ran(1,0,100) < 8) && (town_status(-1) != 2))
		text_bubble_on_char(11,"Humun! Me sell.");
	if ((get_ran(1,0,100) < 8) && (town_status(-1) != 2))
		text_bubble_on_char(12,"Buy something, humun!");
	if ((get_ran(1,0,100) < 8) && (town_status(-1) != 2))
		text_bubble_on_char(13,"Humun! You buy!");


	if ((is_combat() == 1) && (town_status(-1) != 2)) {
		if (get_flag(84,27) == 1) {
			message_dialog("The ogres have had it! Many of them roar in rage and spring at you. The entire village becomes animated with hostility and soon several large brutes have appeared all around you!","Somewhere in the village there is a large magical shock; as if a great deal of magic were released!");
			make_town_hostile();
			set_items_not_property();
			if (get_flag(2,1) == 1)
				erase_char(10);
			erase_char(14);
			put_object_on_space(11,6,4);
			put_object_on_space(12,6,4);
			put_object_on_space(13,6,4);
			place_monster(char_loc_x(0) + 6,char_loc_y(0),234,0);
			place_monster(char_loc_x(0) - 6,char_loc_y(0),234,0);
			place_monster(char_loc_x(0),char_loc_y(0) + 6,234,0);
			place_monster(char_loc_x(0),char_loc_y(0) - 6,234,0);
}
		if (get_flag(84,27) == 0)
			message_dialog("The ogres react strongly to your aggression. Some of them start to shy away from you, but most of them start brandishing weapons of their own. They do not yet seem to be moving in to attack you.","However, that might soon change if you keep your weapons drawn.");
			inc_flag(84,27,1);
}
break;	

beginstate EXIT_STATE;
break;

beginstate 10;

	if (get_flag(3,2) != 0)
		end();

	if ((town_status(-1) == 2) && (get_flag(2,9) == 0)) {
		message_dialog("You speed up your footsteps in hot pursuit of the ogre chieftain. It looks like he has nowhere to run! The magic barriers make small alarm bells chime in your head. Are ogres skilled enough in magic to make these?","Your thinking process is interrupted as your feet step on the rugs on the platform. Apparently the ground underneath them is not as solid as one would have anticipated. The fort disappears from your eyes.");
		set_flag(3,2,2);
		move_to_new_town(3,37,21);
}

	if (town_status(-1) != 2) {
	march_party(10,8);
	force_instant_terrain_redraw();
	play_sound(49);
	pause(3);
	march_party(9,8);
	force_instant_terrain_redraw();
	play_sound(49);
	pause(3);
	march_party(9,7);
	force_instant_terrain_redraw();
	play_sound(49);
	pause(3);
	march_party(9,6);
	force_instant_terrain_redraw();
	play_sound(49);
	pause(3);
	reset_dialog();
	add_dialog_str(0,"The ogres abruptly stop their clamoring. Every wild pair of eyes is focused on their chieftain on the pedestal, on Angerfist. For his part, Angerfist stands like a statue with his arms crossed and stares you straight in the eye.",0);
	add_dialog_str(1,"_You kill many warrior! That is why I can listen you! What say you? What say the humans of the lowlands?_ While they are waiting for your answer, the ogres start to pound the earth with their clubs and feet.",0);
	add_dialog_str(2,"The rhythm is fierce and the ogres' expressions are bloodthirsty.",0);
	add_dialog_choice(0,"We have come to negotiate an end to the bloodshed.");
	add_dialog_choice(1,"The humans of the lowlands demand the ogres to stop their attacks!");
	choice = run_dialog(1);

		if (choice == 1) {
			reset_dialog();
			add_dialog_str(0,"_Nego-tiate?_ The ogres stop clubbing the earth. _Negotiate! Are humans this weak!? We have warred for only few cycles, and already the humans give up!_ The ogre crowd howls its contempt with gusto.",0);
			add_dialog_str(1,"Angerfist's grin widens, revealing his sharp yellow teeth. _Only weak wish for war to end! The ogre people is strong! Why should ogre people stop warring!? Why stop when we win?_",0);
			add_dialog_choice(0,"We must learn to settle our differences without violence.");
			add_dialog_choice(1,"You may have the upper hand now, but the humans are too numerous for you. You will lose.");
			choice = run_dialog(1);

			if (choice == 1) {
				reset_dialog();
				add_dialog_str(0,"_No violence? Ogre people like together with human people? Is it possible to live with humans without violence?_ The ogre crowd stands in silence as it eagerly awaits the answer. _NO!_ Angerfist roars.",0);
				add_dialog_str(1,"The ogres present scream out the same answer. They begin once again to stomp the ground with their clubs and feet. _The ancestors lived on the lowlands with humans!_ Angerfist rages over the noise. _Humans drove them away! To mountains!_",0);
				add_dialog_str(2,"_Humans always wish to kill ogre! Thus is always. You speak like Fool Graybeard._ He says while pointing at you with his greatsword. _But your words are even dumber! The ogre people has quit hiding! Ogre people does not surrender!_",0);
				add_dialog_str(3,"_Ogre people is angry! Raise your fists! For Angerfist!!_ The ogres respond in an ear shattering wall of rage. Each huge fist is striking the sky. This kind of rage can only erupt against something.",0);
				add_dialog_str(4,"You prepare yourselves for a great battle, but then you notice Angerfist moving on the podium. He is holding a chain. He yanks it and the ogre fort disappears from your sight.",0);
				run_dialog(1);
				move_to_new_town(3,37,21);
}

			if (choice == 2) {
				reset_dialog();
				add_dialog_str(0,"_Yes, stories tell us that there have always been more humans than flies in a pile of shit. Ogre people alone cannot defeat humans. So the stories say._ The conversation appears to be heading down the right direction.",0);
				add_dialog_str(1,"The ogre crowd has at least fallen silent. _But is ogre people alone?_ Angerfist cries out and the ogres answer with conviction: _NO!_ and once again begin to hammer the ground.",0);
				add_dialog_str(2,"_No!_ Angerfist confirms. _Ogre people is not alone! Great Witch helps ogre people! Humans cannot defeat ogre people! Ogre people is unstoppable! Angerfist is unstoppable! Raise your fists! For Angerfist!!_",0);
				add_dialog_str(3,"The ogres respond in an ear shattering wall of rage. Each huge fist is striking the sky. This kind of rage can only erupt against something. You prepare yourselves for a fight, but then you notice Angerfist moving on the podium.",0);
				add_dialog_str(4,"He is holding a chain. He yanks it and the ogre fort disappears from your sight.",0);
				run_dialog(1);
				move_to_new_town(3,37,21);
}
}
		if (choice == 2) {
			reset_dialog();
			add_dialog_str(0,"Angerfist laughs his pleasure. _Good! Like Angerfist thought! You are a great warrior. Greatest of lowland humans! That is why you I listen. But your words mean nothing to Angerfist!_ The ogre crowd roars their acceptance.",0);
			add_dialog_str(1,"_Angerfist leads ogre people to great revenge against the lowland humans! But you,_ The ogre chieftain points at you with his greatsword. _You who almost is an ogre. Like ogre, you prove your might in Mighty Beast's den!_",0);
			add_dialog_str(2,"Before you have the chance to do anything, Angerfist is holding a chain. He pulls it and the ground opens up from underneath you and swallows you whole.",0);
			run_dialog(1);
			move_to_new_town(3,37,21);

}
}
 break;

beginstate 11;
	if (town_status(-1) != 2) {
		block_entry(1);
		message_dialog("A nearby ogre brute gestures at you menacingly. _No! Ogre lands! You no come here!_ You think he might attack if you step any closer so you remain where you are.","");
}
 break;

beginstate 12;
	if ((get_flag(2,1) == 0) && (town_status(-1) != 2)) {
		message_dialog("_Approach, human!_ A gruff low voice commands you from above. _Step onto holy rugs and talk to Angerfist!_ When these words come out of the heavily armored ogres mouth, the converging ogres begin to shout and wave their arms.","Their behavior is very aggressive. It feels like the beasts are only waiting for an order to tear you to pieces.");
		set_flag(2,1,1);
}

	if ((get_flag(2,1) == 0) && (town_status(-1) == 2)) {
		set_total_visibility(1);
		force_view_center(11,10);
		force_instant_terrain_redraw();
		pause(4);
		force_view_center(9,5);
		force_instant_terrain_redraw();
		pause(14);
		text_bubble_on_char(10,"Humans come!");
		force_instant_terrain_redraw();
		pause(10);
		text_bubble_on_char(10,"");
		force_instant_terrain_redraw();
		text_bubble_on_char(10,"Need more weapons!");
		force_instant_terrain_redraw();
		pause(10);
		set_character_facing(10,6);
		relocate_character(10,10,4);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(3);
		relocate_character(10,11,4);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(3);
		relocate_character(10,12,4);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(3);
		set_terrain(12,4,53);
		play_sound(-58);
		force_instant_terrain_redraw();
		pause(3);
		set_total_visibility(0);
		force_view_center(char_loc_x(0),char_loc_y(0));
		force_instant_terrain_redraw();
		erase_char(10);
		set_flag(2,1,1);
}
 break;

beginstate 13;
	if (town_status(-1) != 2) {
		block_entry(1);
		message_dialog("A nearby ogre gestures at you aggressively. _No! These ogre homes! No can enter!_ It appears that the ogre is willing to attack you if you try to proceed. Better not enter the buildings for now.","");
}
 break;

beginstate 14;
	if (get_flag(2,4) == 0) {
		message_dialog("The smooth dirt path of the ogres leads into a pit - a gory pit. Traces of blood, stirred ground, yellowing bones, weapons and torn clothes can all be seen at the bottom of the pit.","You think this is some kind of ritual battle pit of the ogres. Although it is currently unused, some of the blood stains look quite fresh.");
		set_flag(2,4,1);
}
 break;

beginstate 15;
	message_dialog("The ogres have carved their altar from pitch black obsidian. There is nothing on it apart from a streak of blood, which runs down all the way to the floor, where in addition to the bright red gore there are also dried brown bloodstains.","You sense no malevolent energy coming from the altar. Apparently whatever evil spirits or demons the ogres worship are not very powerful.");
 break;

beginstate 16;
	if (town_status(-1) != 2) {
		message_dialog("The ogre wizard in purple raises its palm to stop your progress. _No further, human. Step on the holy rugs and address Angerfist._","");
		block_entry(1);
}
 break;

beginstate 17;
	
	if (get_flag(2,8) == 1) {	
		reset_dialog();
		add_dialog_str(0,"Soon you will leave the ogre fort behind. It looks like you have found everything there is to find. Or have you? Do you still want to return to the ogre fort for exploration?",0);
		add_dialog_choice(0,"Yes. I have not found everything yet.");
		add_dialog_choice(1,"No. I am done here.");
		choice = run_dialog(1);

		if (choice == 2) {
			message_dialog("From now on you can walk right past the Ogre Fort in the outdoor map.","");
			set_town_visibility(2,0);
}
}
 break;

beginstate 18;
	
	if ((get_flag(2,1) == 0) && (town_status(-1) == 2)) {
		set_total_visibility(1);
		force_view_center(11,10);
		force_instant_terrain_redraw();
		pause(4);
		force_view_center(9,5);
		force_instant_terrain_redraw();
		pause(14);
		text_bubble_on_char(10,"Humans come!");
		force_instant_terrain_redraw();
		pause(10);
		text_bubble_on_char(10,"");
		force_instant_terrain_redraw();
		text_bubble_on_char(10,"Need more weapons!");
		force_instant_terrain_redraw();
		pause(10);
		set_character_facing(10,6);
		relocate_character(10,10,4);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(3);
		relocate_character(10,11,4);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(3);
		relocate_character(10,12,4);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(3);
		set_terrain(12,4,53);
		play_sound(-58);
		force_instant_terrain_redraw();
		pause(3);
		set_total_visibility(0);
		force_view_center(char_loc_x(0),char_loc_y(0));
		force_instant_terrain_redraw();
		erase_char(10);
		set_flag(2,1,1);
}
 break;

beginstate 19;
	if ((get_flag(2,1) == 0) && (town_status(-1) == 2)) {
		message_dialog("You cannot leave the fort now! You must find out if the ogre chieftain is here and kill him.","");
		block_entry(1);
}
 break;